﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telerik.Web.Mvc;
using PeopleSource.Utl;
using PeopleSource.Entities;

namespace PeopleSource.Controllers
{
    public class JobTitleController : Controller
    {
        public ActionResult Index()
        {

            return View();
        }

        [GridAction]
        public ActionResult _SelectIndex(int? conferenceid)
        {
            return View(new GridModel(CH.GetAllDatas<JobTitle>()));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult _SaveAjaxEditing(int? id, int? conferenceid)
        {
            var item = CH.GetDataByID<JobTitle>(id);
            if (TryUpdateModel(item))
            {
                CH.Edit<JobTitle>(item);
            }
            return View(new GridModel(CH.GetAllDatas<JobTitle>()));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult _InsertAjaxEditing()
        {
            var item = new JobTitle();

            if (TryUpdateModel(item))
            {
                CH.Create<JobTitle>(item);
            }
            return View(new GridModel(CH.GetAllDatas<JobTitle>()));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult _DeleteAjaxEditing(int? id)
        {
            CH.Delete<JobTitle>(id);
            return View(new GridModel(CH.GetAllDatas<JobTitle>()));
        }

    }
}
